package cate.common.table.show.sheet;

import cate.common.table.ESheet;
import cate.common.table.d.GDBlog;
import cate.common.table.show.row.AvartarRow;
import easy.java.dev.note.NoteClass;

import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;

@NoteClass("冒险形象")
public class AvartarSheet extends ESheet<AvartarRow> {

    @Override
    public String getSheetName() {
        return "冒险形象";
    }

    public AvartarRow findDefaultRow(byte sex) {
        for (AvartarRow row : this.getList()) {
            if (row.activeType == GDBlog.ActiveType.SEX && row.value == sex) {
                return row;
            }
        }
        return null;
    }

    public AvartarRow random() {
        List<AvartarRow> collect = getList().stream()
                .collect(Collectors.toList());
        Random random = new Random();
        int r = random.nextInt(collect.size());
        return collect.get(r);
    }
}
